<?php

include_once 'HelperDAO.class.php';

class LookupsDAO {

    /**
     * @var $helperDAO HelperDAO
     */
    private $helperDAO;

    /**
     *
     */
    function __construct($config=false) {
        $this->helperDAO = new HelperDAO($config);
    }

    function get($tableName,$id){
        return $this->helperDAO->select("SELECT * FROM %s WHERE id = %s ", array($tableName,$id),true);
    }
    function listAll($tableName){
        return $this->helperDAO->select("SELECT * FROM %s", array($tableName));
    }
    function edit($tableName,$name,$id){
        return $this->helperDAO->update("UPDATE %s set name = '%s' WHERE id=%s", array($tableName,$name,$id));
    }

    function save($tableName,$name){
        return $this->helperDAO->insert("INSERT INTO %s (name) VALUES ('%s')", array($tableName,$name));
    }

    function Delete($tableName,$delete,$id){
        return $this->helperDAO->delete("UPDATE %s SET isDeleted = '%s' WHERE id = '%s'", array($tableName,$delete,$id));
    }

}